package com.cindata

import com.cindata.dictionary.*

class AccountProjectBuilding
{

    String name
    // 楼盘名称
    String address
    // 楼盘地址
    String certificateNumber
    // 资质证书编号
    Double coveringArea
    // 占地面积（平方米）
    Double totalBuildingArea
    // 总建筑面积（平方米）
    BuildingTypeDict buildingType
    // 建筑类型


    // 国土证

    Date createdDate = new Date()
    Date modifiedDate = new Date()
    User user
    User createBy
    User modifyBy

    static belongsTo = [project: AccountProject]

    static mapping = {
        autowire true
    }

    static constraints = {
        name maxSize: 50, nullable: true, blank: true, comment: '楼盘名称'
        address maxSize: 150, nullable: true, blank: true, comment: '楼盘地址'
        certificateNumber maxSize: 50, nullable: true, blank: true, comment: '资质证书编号'
        coveringArea nullable: true, blank: true, comment: '占地面积（平方米）'
        totalBuildingArea nullable: true, blank: true, comment: '总建筑面积（平方米）'
        buildingType nullable: true, blank: true, comment: '用途性质'

        createdDate nullable: true, blank: true
        modifiedDate nullable: true, blank: true
        user nullable: true, blank: true
        createBy nullable: true, blank: true
        modifyBy nullable: true, blank: true
    }

    def springSecurityService
    def beforeInsert()
    {
        def username = springSecurityService?.getPrincipal()?.username
        createBy = User.findByUsername(username)
    }

    def beforeUpdate()
    {
        modifiedDate = new Date()
        def username = springSecurityService?.getPrincipal()?.username
        modifyBy = User.findByUsername(username)
    }
}

